package com.wn.user.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.stereotype.Service;

/**
 * @author yellow Docter
 * @date 2022 -08-30
 * @desc
 */
@Service
public class MyService {

    // 将此方法标注为sentinel的资源。value=资源名

    /**
     * 如果  出现了 流控  可以进行服务降级
     *     fallback  流控了,执行 exceptionHandler这个方法
     *
     * @return
     */
    @SentinelResource(value = "some",fallback = "exceptionHandler")
    public String doSomething(){
        System.out.println("doSomething...");
        return "doSomething";
    }

    public String exceptionHandler(){
        System.out.println("doSomething: 发生流控");
        return "MyServiceImpl doSomething 发生流控";
    }

}
